home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
putz
/
putzdo.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
15KB
|
450 lines
IMPLEMENTATION MODULE PutzDo;
FROM SYSTEM IMPORT ADDRESS, ADR, CADR, TSIZE, BYTE, ASSEMBLER, CALLSYS;
(* MM2 *)
FROM Storage IMPORT ALLOCATE, DEALLOCATE, MemAvail;
FROM Lists IMPORT List, CreateList, DeleteList,
AppendEntry, ListEmpty, CurrentEntry,
NextEntry, ResetList, RemoveEntry,
ScanEntries, LDir, LCondProc,
NoOfEntries, PrevEntry;
(* MagicLib *)
IMPORT MagicStrings, MagicTypes;
(* magic tools *)
IMPORT mtDials, mtAlerts;
(* CatPutz *)
FROM PutzTypes IMPORT grListEntry, ptrGrEntry, defaultOpts, delState,
totalEntry, putzList, groupList, displayList,
listEntryType, displayListEntry, ptrDispEntry;
FROM PutzRsc IMPORT menu, ReplaceStr;
IMPORT Catputz2;
IMPORT PutzLog, PutzTypes, PutzAction, PutzGroup, PutzWindows;
(* CAT *)
IMPORT dataSys, ConvertDate, ConfVars, MTPaths;
FROM Void IMPORT v;
(* Operationen auf der Gruppenliste *)
PROCEDURE CountSelectedEntries (gr: List): INTEGER;
VAR count : INTEGER;
entry : ptrGrEntry;
BEGIN
count := 0;
ResetList (gr);
WHILE NextEntry (gr) # NIL DO
entry := CurrentEntry (gr);
IF entry^.selected THEN INC (count); END;
END;
RETURN count;
END CountSelectedEntries;
PROCEDURE FirstSelectedGroup (gr : List) : ADDRESS;
VAR entry : ptrGrEntry;
BEGIN
ResetList (gr);
WHILE NextEntry (gr) # NIL DO
entry := CurrentEntry (gr);
IF entry^.selected THEN RETURN entry END;
END;
RETURN NIL
END FirstSelectedGroup;
PROCEDURE NextSelectedGroup (gr : List; currentGroup: INTEGER) : ADDRESS;
VAR entry : ptrGrEntry;
i : INTEGER;
BEGIN
ResetList (gr);
REPEAT
entry := NextEntry (gr);
IF entry # NIL
THEN
i := entry^.info^.catNumber
END;
UNTIL (i=currentGroup) OR (entry=NIL);
IF entry = NIL THEN RETURN -1 END;
WHILE NextEntry (gr) # NIL DO
entry := CurrentEntry (gr);
IF entry^.selected THEN RETURN entry END;
END;
RETURN NIL
END NextSelectedGroup;
PROCEDURE GetGroupEntry (index : INTEGER) : ptrGrEntry;
CONST emptyName = " ";
VAR i : INTEGER;
entry : ptrGrEntry;
BEGIN
ResetList (putzList);
REPEAT
entry := NextEntry (putzList);
IF entry # NIL
THEN
i := entry^.info^.catNumber
END;
UNTIL (i=index) OR (entry=NIL);
RETURN entry;
END GetGroupEntry;
PROCEDURE SelectAll( select : BOOLEAN);
VAR entry : ptrGrEntry;
BEGIN
ResetList (putzList);
WHILE NextEntry (putzList) # NIL DO
entry := CurrentEntry (putzList);
IF ~((entry^.info^.catNumber = dataSys.private) & select)
THEN entry^.selected := select;
END;
END;
END SelectAll;
PROCEDURE CalcTotals;
VAR entry : ptrGrEntry;
PROCEDURE addIt ();
BEGIN
WITH entry^ DO
INC (totalEntry.preMsgs, preMsgs);
INC (totalEntry.preBytes, preBytes);
IF postBytes # 0
THEN
INC (totalEntry.postBytes, postBytes)
ELSE
INC (totalEntry.postBytes, preBytes);
END;
IF postMsgs # 0
THEN
INC (totalEntry.postMsgs, postMsgs)
ELSE
INC (totalEntry.postMsgs, preMsgs);
END;
INC (totalEntry.badDel, badDel);
INC (totalEntry.totalDel, totalDel);
INC (totalEntry.partDel, partDel);
END;
END addIt;
BEGIN
totalEntry.preMsgs := 0;
totalEntry.preBytes := 0;
totalEntry.badDel := 0;
totalEntry.totalDel := 0;
totalEntry.partDel := 0;
totalEntry.postMsgs := 0;
totalEntry.postBytes := 0;
(* entry := ADR(persGroup);
addIt();
*)
ResetList (putzList);
entry := NextEntry (putzList);
WHILE entry # NIL DO
addIt();
entry := NextEntry (putzList);
END;
END CalcTotals;
PROCEDURE PerformDelete(wdwHandle: INTEGER);
VAR i : CARDINAL;
ch : CHAR;
oCurrGr : INTEGER;
currGrEntry : ptrGrEntry;
rdB : LONGCARD;
putzOpts : PutzTypes.putzOptsRec;
success : BOOLEAN;
BEGIN
currGrEntry := FirstSelectedGroup(putzList);
IF currGrEntry = NIL THEN RETURN END;
PutzAction.InitActionBox ();
WHILE currGrEntry # NIL DO
putzOpts := InitGroupFlags (currGrEntry^.info^.catNumber, TRUE, success);
IF ~success THEN
PutzAction.ReleaseActionBox();
RETURN
END;
IF ~PutzGroup.deleteInGroup (currGrEntry, putzOpts, PutzTypes.dFlags)
THEN
PutzAction.ReleaseActionBox();
RETURN
END;
IF PutzWindows.IsPutzWindow (wdwHandle)
THEN
CalcTotals();
IF putzOpts.deselAfterDel
THEN
PutzWindows.DeselectEntry (wdwHandle, currGrEntry);
END;
PutzWindows.RedrawEntry (wdwHandle, currGrEntry);
PutzWindows.RedrawEntry (wdwHandle, ADR(totalEntry));
END;
(* Nchste Gruppe suchen *)
currGrEntry := NextSelectedGroup(putzList, currGrEntry^.info^.catNumber);
END;
PutzAction.ReleaseActionBox();
END PerformDelete;
PROCEDURE InitDelete (wdwHandle: INTEGER);
VAR currGrEntry: ptrGrEntry;
BEGIN
currGrEntry := FirstSelectedGroup(putzList);
IF currGrEntry = NIL THEN RETURN END;
(* Menu disablen *)
mtDials.DisableMenu (menu, TRUE);
(* Lschen durchfhren *)
IF PutzLog.OpenLog (MTPaths.DataPath) THEN END;
PutzLog.putTime();
PutzLog.WriteString (PutzTypes.version);
PutzLog.WriteString (" fr CAT 3.x gestartet");
PutzLog.WriteLn;
PerformDelete (wdwHandle);
(* Ok, das war's, weiter im normalen Programm *)
CalcTotals;
PutzLog.WriteString ("--------------------------------------------------");
PutzLog.WriteLn;
PutzLog.putTime ();
PutzLog.WriteString (" Lschen beendet.");
PutzLog.WriteLn;
PutzLog.WriteLine ("STATISTIK: ");
PutzLog.WriteString (" Gesamtanzahl Messages vorher: ");
PutzLog.WriteCard (totalEntry.preMsgs);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl Messages nachher: ");
PutzLog.WriteCard (totalEntry.postMsgs);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl totalgelschter Messages: ");
PutzLog.WriteCard (totalEntry.totalDel);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl teilgelschter Messages: ");
PutzLog.WriteCard (totalEntry.partDel);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl beschdigter Messages: ");
PutzLog.WriteCard (totalEntry.badDel);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl Bytes vorher: ");
PutzLog.WriteCard (totalEntry.preBytes);
PutzLog.WriteLn;
PutzLog.WriteString (" Gesamtanzahl Bytes nachher: ");
PutzLog.WriteCard (totalEntry.postBytes);
PutzLog.WriteLn;
PutzLog.WriteLn;
PutzLog.CloseLog();
(* Menu wiederherstellen *)
mtDials.DisableMenu (menu, FALSE);
END InitDelete;
PROCEDURE InitGroupFlags (groupIndex: INTEGER; doAlts: BOOLEAN; VAR ok: BOOLEAN): PutzTypes.putzOptsRec;
VAR ptr: ptrGrEntry;
gName: PutzTypes.groupName;
varName : PutzTypes.groupName;
val : INTEGER;
boolVal : BOOLEAN;
delStr : PutzTypes.groupName;
putzOpts: PutzTypes.putzOptsRec;
BEGIN
ptr := GetGroupEntry (groupIndex);
ok := TRUE;
IF ptr # NIL
THEN
(* Gruppennamen von Leerzeichen befreien *)
MagicStrings.Assign (ptr^.info^.name^, gName);
MagicStrings.CAPS (gName);
ReplaceStr (gName, ' ','_'); (* Spaces durch Underscores ersetzen *)
(* Variablennamen zusammenbauen *)
(* Fr Interessant-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delInteresting', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.intFlag));
putzOpts.intFlag := delState (val);
(* Fr User-Flag 1 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag1', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.usrFlg1));
putzOpts.usrFlg1 := delState (val);
(* Fr User-Flag 2 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag2', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.usrFlg2));
putzOpts.usrFlg2 := delState (val);
(* Fr Gelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delRead', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.readFlg));
putzOpts.readFlg := delState (val);
(* Fr Gefiltert-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delFiltered', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.filtFlg));
putzOpts.filtFlg := delState (val);
(* Fr Ungelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUnread', varName);
ConfVars.GetConfDefInt (varName, val, ORD(defaultOpts.noRdFlg));
putzOpts.noRdFlg := delState (val);
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteByDate', varName);
ConfVars.GetConfDefBool (varName, boolVal, defaultOpts.deleteByDate);
putzOpts.deleteByDate := boolVal;
IF boolVal
THEN
(* Datum holen *)
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteDate', varName);
ConfVars.GetConfDefStr (varName, delStr, defaultOpts.dateStr);
MagicStrings.Assign (delStr, putzOpts.dateStr);
IF ConvertDate.DateOk (delStr)
THEN
putzOpts.delDate := ConvertDate.StrToDate (delStr);
IF putzOpts.delDate > ConvertDate.CurrentDate ()
THEN
(* Fehlermeldung! *)
IF doAlts
THEN
v.int := mtAlerts.Alert (1,"[3][CATPUTZ:|Das Lschdatum ist|grer als das Tagesdatum.][[Abbruch]");
END;
ok := FALSE;
END;
ELSE
IF doAlts THEN
v.int := mtAlerts.Alert (1,"[3][CATPUTZ:|Das Lschdatum ist|nicht gltig.][[Abbruch]");
END;
ok := FALSE;
END;
ELSE
MagicStrings.Assign ('', putzOpts.dateStr);
END;
putzOpts.useTmp := defaultOpts.useTmp;
putzOpts.tmpLock := defaultOpts.tmpLock;
putzOpts.deselAfterDel := defaultOpts.deselAfterDel;
MagicStrings.Assign (defaultOpts.tmpDir, putzOpts.tmpDir);
putzOpts.delWithoutComm := defaultOpts.delWithoutComm;
ELSE
(* Default nehmen *)
putzOpts := defaultOpts;
END;
RETURN putzOpts;
END InitGroupFlags;
PROCEDURE SetGroupFlags (groupIndex: INTEGER; REF putzOpts: PutzTypes.putzOptsRec);
VAR ptr: ptrGrEntry;
gName: PutzTypes.groupName;
varName : PutzTypes.groupName;
val : INTEGER;
boolVal : BOOLEAN;
delStr : PutzTypes.groupName;
BEGIN
ptr := GetGroupEntry (groupIndex);
IF ptr # NIL
THEN
(* Gruppennamen von Leerzeichen befreien *)
MagicStrings.Assign (ptr^.info^.name^, gName);
MagicStrings.CAPS (gName);
ReplaceStr (gName, ' ','_'); (* Spaces durch Underscores ersetzen *)
(* Variablennamen zusammenbauen *)
(* Fr Interessant-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delInteresting', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.intFlag));
(* Fr User-Flag 1 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag1', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.usrFlg1));
(* Fr User-Flag 2 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag2', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.usrFlg2));
(* Fr Gelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delRead', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.readFlg));
(* Fr Gefiltert-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delFiltered', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.filtFlg));
(* Fr Ungelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUnread', varName);
v.bool := ConfVars.SetConfigInt (varName, ORD(putzOpts.noRdFlg));
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteByDate', varName);
v.bool := ConfVars.SetConfigBool (varName, putzOpts.deleteByDate);
IF putzOpts.deleteByDate
THEN
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteDate', varName);
v.bool := ConfVars.SetConfigString (varName, putzOpts.dateStr);
END;
END;
END SetGroupFlags;
PROCEDURE DeleteGroupFlags (groupIndex: INTEGER);
VAR ptr: ptrGrEntry;
gName: PutzTypes.groupName;
varName : PutzTypes.groupName;
val : INTEGER;
boolVal : BOOLEAN;
delStr : PutzTypes.groupName;
BEGIN
ptr := GetGroupEntry (groupIndex);
IF ptr # NIL
THEN
(* Gruppennamen von Leerzeichen befreien *)
MagicStrings.Assign (ptr^.info^.name^, gName);
MagicStrings.CAPS (gName);
ReplaceStr (gName, ' ','_'); (* Spaces durch Underscores ersetzen *)
(* Variablennamen zusammenbauen *)
(* Fr Interessant-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delInteresting', varName);
ConfVars.DeleteConfigVar (varName);
(* Fr User-Flag 1 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag1', varName);
ConfVars.DeleteConfigVar (varName);
(* Fr User-Flag 2 *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUserflag2', varName);
ConfVars.DeleteConfigVar (varName);
(* Fr Gelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delRead', varName);
ConfVars.DeleteConfigVar (varName);
(* Fr Gefiltert-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delFiltered', varName);
ConfVars.DeleteConfigVar (varName);
(* Fr Ungelesen-Flag *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.delUnread', varName);
ConfVars.DeleteConfigVar (varName);
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteByDate', varName);
ConfVars.DeleteConfigVar (varName);
(* Lschdatum zusammensetzen *)
MagicStrings.Assign (gName, varName);
MagicStrings.Append ('.deleteDate', varName);
ConfVars.DeleteConfigVar (varName);
END;
END DeleteGroupFlags;
END PutzDo.